"Playing" With Filters

Okay, so I'm not playing with Word anymore, now I'm trying to figure out filters.  Here is my question:  I am trying to create a program which will use one filter, but the one filter is combination of many filters.  However, I won't know how many filters I am going to have.  (Basically, I'm doing a filter to find a specific CR, then have a for loop to figure out how many objects are in the filtered module.  My problem comes in the next part of the program.  I want to do something that I don't see why it wouldn't be possible:

1) Initialize a string array called "filters" which is "j" long (j was previously defined as the number of objects in my module)

2) Loop through all of the objects, each time:

2A) Finding the length of the "Object Number" Attribute

2B) Finding the last period in the "Object Number" attribute

2C) Taking a substring of the "Object Number" attribute from the beginning of the attribute to the last period

Then I want to:

2D) make the filters array (at index "L", where L is 0, and then incremented as each index is filled) equal the following filter (putting it in as a string, since I'm not sure that I can create an array of filters?):

filters[L] = "contains(attribute ""Object Number"". objNumShort, false)"       //(where objNumShort is the substring of the Object Number attribute)

Then I want to do something like:

int k = 0

Filter f3 = filters[k]

for(k = 1; k <= L; k++)

{

f3 = f3 + "||" + filters[k]

}

 

I'm getting errors in the places that I italicized, and I'm having problems figuring out what is wrong.  Since you can just type a filter in as a "string", shouldn't this work to make f3 be all of the filters in the "filters" array "OR'ed" together?  And if not, any ideas as to what I could do to fix this?

Thanks!


josiah820 - Thu May 30 15:32:56 EDT 2013

Re: "Playing" With Filters
josiah820 - Thu May 30 15:35:26 EDT 2013

I guess it would be wrong to say I'm trying to "figure out" filters... I'm trying to dig deeper into filters...

Re: "Playing" With Filters
llandale - Fri May 31 14:35:35 EDT 2013

If you figure to save a view perhaps "CR 221 View" showing all objects associated with CR #221 then you want to use "Filters".  Otherwise I think you do not.  If you just wish to make some report or just, for now, show objects associated it is easier to just evaluate each Object and "accept" or "reject" it.

  • current = mod
  • filtering off
  • for o in entire mod do
  • {  reject(o)
  •    if (isDeleted(o)) continue
  •    if (this object is associated with my CR)
  •    {  accept(o)
  •       oParent = parent(o)
  •       if (!null oParent then accept(oParent)
  •    }
  • }
  • filtering on

Accept/reject filters cannot be saved in a view.

As for your code snippette

[1] I notice your period-prefix algorithm, when encounting text object "3.2.0-2" will result in a Filter " Object Number contains "3.2"", which will match object 4.3.2 as well as 3.2, which is not what you want.  Perhaps use Absolute Number instead.

[2] ... you can "or" the "Filters" or "or" the "strings", but not both at the same time.  You may not concatenate a 'string' with a 'Filter'.  I don't know what your plus signs are doing.  I think you want this:\

  • if (I want to display o) then
  • {  filt = filter(equals(attribute "Absolute Number", o."Absolute Number"); whatever-the-syntax)
  •    filt = filt or filter(equals(attribute "Absolute Number", (parent(o))."Absolute Number"); whatever-the-syntax
  •    filters[L++] = filt
  • }
  • //
  • Filter f3 = null
  • for(k = 0; k <= L; k++)
  • {  f3 = f3 or filters(k)
  • }
  • apply f3 to module, whatever-the-syntax-is

-Louie

Re: "Playing" With Filters
josiah820 - Fri May 31 15:15:37 EDT 2013

llandale - Fri May 31 14:35:35 EDT 2013

If you figure to save a view perhaps "CR 221 View" showing all objects associated with CR #221 then you want to use "Filters".  Otherwise I think you do not.  If you just wish to make some report or just, for now, show objects associated it is easier to just evaluate each Object and "accept" or "reject" it.

  • current = mod
  • filtering off
  • for o in entire mod do
  • {  reject(o)
  •    if (isDeleted(o)) continue
  •    if (this object is associated with my CR)
  •    {  accept(o)
  •       oParent = parent(o)
  •       if (!null oParent then accept(oParent)
  •    }
  • }
  • filtering on

Accept/reject filters cannot be saved in a view.

As for your code snippette

[1] I notice your period-prefix algorithm, when encounting text object "3.2.0-2" will result in a Filter " Object Number contains "3.2"", which will match object 4.3.2 as well as 3.2, which is not what you want.  Perhaps use Absolute Number instead.

[2] ... you can "or" the "Filters" or "or" the "strings", but not both at the same time.  You may not concatenate a 'string' with a 'Filter'.  I don't know what your plus signs are doing.  I think you want this:\

  • if (I want to display o) then
  • {  filt = filter(equals(attribute "Absolute Number", o."Absolute Number"); whatever-the-syntax)
  •    filt = filt or filter(equals(attribute "Absolute Number", (parent(o))."Absolute Number"); whatever-the-syntax
  •    filters[L++] = filt
  • }
  • //
  • Filter f3 = null
  • for(k = 0; k <= L; k++)
  • {  f3 = f3 or filters(k)
  • }
  • apply f3 to module, whatever-the-syntax-is

-Louie


I can't use Absolute Number, because I'm trying to "Level Up".  For example, If object number 5.12.3.4.2 is effected by CR00012, I'm trying to get ALL of the objects that start with 5.12.3.4.  I have an idea for this, and I'm going to try it with the "accept"/"reject" system.

Re: "Playing" With Filters
llandale - Fri May 31 16:11:03 EDT 2013

josiah820 - Fri May 31 15:15:37 EDT 2013


I can't use Absolute Number, because I'm trying to "Level Up".  For example, If object number 5.12.3.4.2 is effected by CR00012, I'm trying to get ALL of the objects that start with 5.12.3.4.  I have an idea for this, and I'm going to try it with the "accept"/"reject" system.

You want the single parent and all that parent's children included?  Are you sure you don't just want all the ancestors of your accepted object?

  • 3.  Requirement
  • 3.2 Whatever
  • 3.2.4  whatever
  • 3.2.4.0_3 My Requirement

there is an "ancestors" feature of the filter you could turn on.

-Louie

 

Re: "Playing" With Filters
josiah820 - Mon Jun 03 08:39:54 EDT 2013

llandale - Fri May 31 16:11:03 EDT 2013

You want the single parent and all that parent's children included?  Are you sure you don't just want all the ancestors of your accepted object?

  • 3.  Requirement
  • 3.2 Whatever
  • 3.2.4  whatever
  • 3.2.4.0_3 My Requirement

there is an "ancestors" feature of the filter you could turn on.

-Louie

 

I know about the ancestors feature.  I tried using it (and did so successfully), but it's not what my supervisor wants.  He wants the single parent of the object and all of the objects "siblings".

Re: "Playing" With Filters
llandale - Tue Jun 04 12:11:31 EDT 2013

josiah820 - Mon Jun 03 08:39:54 EDT 2013

I know about the ancestors feature.  I tried using it (and did so successfully), but it's not what my supervisor wants.  He wants the single parent of the object and all of the objects "siblings".

So for req "R", you want "R"s parent and all of "R"s siblings.  Try this:

  • Object oCurr = current
  • Object oParent, oChild
  • oParent = parent(oCurr)  // get the parent object
  • print identifier(oParent) " ...Children ...\n"
  • for oChild in oParent do    // get each immediate child of oParent
  • {  print "\t" identifier(oChild) "\n"
  •    if (oChild == oCurr) then print "\t\tIs My Original Object!n"
  • }

-Louie

Re: "Playing" With Filters
josiah820 - Tue Jun 04 13:40:20 EDT 2013

llandale - Tue Jun 04 12:11:31 EDT 2013

So for req "R", you want "R"s parent and all of "R"s siblings.  Try this:

  • Object oCurr = current
  • Object oParent, oChild
  • oParent = parent(oCurr)  // get the parent object
  • print identifier(oParent) " ...Children ...\n"
  • for oChild in oParent do    // get each immediate child of oParent
  • {  print "\t" identifier(oChild) "\n"
  •    if (oChild == oCurr) then print "\t\tIs My Original Object!n"
  • }

-Louie

Okay, thanks! But I'm getting a null Object do loop parameter was passed error for some reason.  I've attached my code.  Also, is there a way to "override" the filter, while still leaving it on?  I want to show the parent and siblings of the object which were modified by a CR, but still be able to loop through the rest of the objects that were modified by the CR and show their parent and siblings.  Is this possible?  I've done everything that I can think to do.

Thanks!


Attachments

CR-CRG In Project Level Up.dxl

Re: "Playing" With Filters
llandale - Tue Jun 04 15:12:34 EDT 2013

josiah820 - Tue Jun 04 13:40:20 EDT 2013

Okay, thanks! But I'm getting a null Object do loop parameter was passed error for some reason.  I've attached my code.  Also, is there a way to "override" the filter, while still leaving it on?  I want to show the parent and siblings of the object which were modified by a CR, but still be able to loop through the rest of the objects that were modified by the CR and show their parent and siblings.  Is this possible?  I've done everything that I can think to do.

Thanks!

  • Line #76 you don't need to reload the module with "read m".
  • Line #77 you want "current = m"; not "m = current".
  • In fact; I don't think you should ever need to "m = current"; that changes "m" (such as line #39).
  • Line #85 "pragma runLim, 0" should go at the top of the file
  • Line #50+, My code above was an example, you should not use it litterally.  probably the 1st object in the module is "current"; and it has no parent.  check for nulls.

I think you are saying that you want to "filter" for objects associated with a particular CR; then show that object, it's immediate parent, and all it's immediate siblings.  If so, I would do this:

  • Run the filter
  • Capture all the displayed objects
  • turn off the filter; reload your view
  • for each object (in your normal view)
    • reject each object
  • for each object (your normal view )
    • If this object was originally filtered then "accept" it; it's parent' and all it's parents children objects
  • turn filtering on.

That may look like this

  • apply your filter after reading the file
  • current = m
  • filtering off
  • Skip skpFiltered = create()    // KEY and DATA both 'Object'
  • for o in m do
  • {  reject o
  • }
  • for o in m do
  • {  if (!find(skpFiltered, o))     continue    // don't want to see this object
  •    accept(o)
  •    oParent = parent(o)
  •    accept(oParent)
  •    for oChild in oParent do
  •    {  accept(oChild)
  •    }
  • }
  • filtering on

So.  You need to understand:

  • A true "Filter" is when you specify criteria such as "contains XYZ".  You can save that in a view.
  • An "accept/reject" "Filter" is fundamentally different.  You apply your desired criteria to each object separately; either "accept" or "reject" it, then turn the filter on.  You cannot save this "Filter" in a view.
  • the "for o in entire m do" loop ignores the current filter and display and gets EVERY object.
  • the "for o in m do" loop only sees currently displayed objects.  I displike this loop because it is at the mercy of the current view.

-Louie

Re: "Playing" With Filters
josiah820 - Wed Jun 05 09:06:50 EDT 2013

llandale - Tue Jun 04 15:12:34 EDT 2013

  • Line #76 you don't need to reload the module with "read m".
  • Line #77 you want "current = m"; not "m = current".
  • In fact; I don't think you should ever need to "m = current"; that changes "m" (such as line #39).
  • Line #85 "pragma runLim, 0" should go at the top of the file
  • Line #50+, My code above was an example, you should not use it litterally.  probably the 1st object in the module is "current"; and it has no parent.  check for nulls.

I think you are saying that you want to "filter" for objects associated with a particular CR; then show that object, it's immediate parent, and all it's immediate siblings.  If so, I would do this:

  • Run the filter
  • Capture all the displayed objects
  • turn off the filter; reload your view
  • for each object (in your normal view)
    • reject each object
  • for each object (your normal view )
    • If this object was originally filtered then "accept" it; it's parent' and all it's parents children objects
  • turn filtering on.

That may look like this

  • apply your filter after reading the file
  • current = m
  • filtering off
  • Skip skpFiltered = create()    // KEY and DATA both 'Object'
  • for o in m do
  • {  reject o
  • }
  • for o in m do
  • {  if (!find(skpFiltered, o))     continue    // don't want to see this object
  •    accept(o)
  •    oParent = parent(o)
  •    accept(oParent)
  •    for oChild in oParent do
  •    {  accept(oChild)
  •    }
  • }
  • filtering on

So.  You need to understand:

  • A true "Filter" is when you specify criteria such as "contains XYZ".  You can save that in a view.
  • An "accept/reject" "Filter" is fundamentally different.  You apply your desired criteria to each object separately; either "accept" or "reject" it, then turn the filter on.  You cannot save this "Filter" in a view.
  • the "for o in entire m do" loop ignores the current filter and display and gets EVERY object.
  • the "for o in m do" loop only sees currently displayed objects.  I displike this loop because it is at the mercy of the current view.

-Louie

Okay, I made some changes to the code and I THINK I made the right changes, but it's acting weird.  I edited my test module and put CR00444 into the "CR" attribute in one object.  However, when I run the program, every single object is "grayed out" (I'm assuming that means it was "rejected". yet EVERY object is exported in the "Export to Word" box.  Does accepting and rejecting not have any effect on if the object is exported or not, and how can I "hide" the objects that I don't want to be exported, based on what was accepted or rejected, so that only the "accepted" objects are included in the export?

Thanks for your help


Attachments

CR-CRG In Project Level Up.dxl

Re: "Playing" With Filters
GregM_dxler - Wed Jun 05 09:45:42 EDT 2013

josiah820 - Wed Jun 05 09:06:50 EDT 2013

Okay, I made some changes to the code and I THINK I made the right changes, but it's acting weird.  I edited my test module and put CR00444 into the "CR" attribute in one object.  However, when I run the program, every single object is "grayed out" (I'm assuming that means it was "rejected". yet EVERY object is exported in the "Export to Word" box.  Does accepting and rejecting not have any effect on if the object is exported or not, and how can I "hide" the objects that I don't want to be exported, based on what was accepted or rejected, so that only the "accepted" objects are included in the export?

Thanks for your help

It's probably a little late, but I did something similar to filter for change request changes.  For our reviews for a CR, we wanted to include the entire section where a proposed change was being made.  Made it easier to review the change in it's context and also was easier to see what another object also needed a change.

The filter was done by using a string array that got converted into the appropriate filter.

I used a regular expression ([0-9.]+)(.0-[0-9]) on the object number so I could get the section.  All of our text below headers are one level down and so have the format of xxx.xxx.0-xxx.  Then after capturing each affected section, I stripped off the ending period and saved it in the 'section' array.  I then made a loop through the array and built my filter by making a filter filt= filt || attribute "Object Number" >= section[cnt].  (actually it was a little more complicated than this, but this gives the general idea).

I then applied the filter and refreshed the module.  You could do something similar by finding the affected object, getting the object number and stripping the higher levels off, then making a filter of the object number.

Hope this helps,

Greg

Re: "Playing" With Filters
josiah820 - Wed Jun 05 09:57:53 EDT 2013

GregM_dxler - Wed Jun 05 09:45:42 EDT 2013

It's probably a little late, but I did something similar to filter for change request changes.  For our reviews for a CR, we wanted to include the entire section where a proposed change was being made.  Made it easier to review the change in it's context and also was easier to see what another object also needed a change.

The filter was done by using a string array that got converted into the appropriate filter.

I used a regular expression ([0-9.]+)(.0-[0-9]) on the object number so I could get the section.  All of our text below headers are one level down and so have the format of xxx.xxx.0-xxx.  Then after capturing each affected section, I stripped off the ending period and saved it in the 'section' array.  I then made a loop through the array and built my filter by making a filter filt= filt || attribute "Object Number" >= section[cnt].  (actually it was a little more complicated than this, but this gives the general idea).

I then applied the filter and refreshed the module.  You could do something similar by finding the affected object, getting the object number and stripping the higher levels off, then making a filter of the object number.

Hope this helps,

Greg

That was actually my original idea.  I think I was running into issues because I was trying to use the "contains" filter, maybe it'll work better if I use >=.  Thanks!

Re: "Playing" With Filters
josiah820 - Wed Jun 05 10:27:42 EDT 2013

GregM_dxler - Wed Jun 05 09:45:42 EDT 2013

It's probably a little late, but I did something similar to filter for change request changes.  For our reviews for a CR, we wanted to include the entire section where a proposed change was being made.  Made it easier to review the change in it's context and also was easier to see what another object also needed a change.

The filter was done by using a string array that got converted into the appropriate filter.

I used a regular expression ([0-9.]+)(.0-[0-9]) on the object number so I could get the section.  All of our text below headers are one level down and so have the format of xxx.xxx.0-xxx.  Then after capturing each affected section, I stripped off the ending period and saved it in the 'section' array.  I then made a loop through the array and built my filter by making a filter filt= filt || attribute "Object Number" >= section[cnt].  (actually it was a little more complicated than this, but this gives the general idea).

I then applied the filter and refreshed the module.  You could do something similar by finding the affected object, getting the object number and stripping the higher levels off, then making a filter of the object number.

Hope this helps,

Greg

Do you happen to have the actual code for just the filter line and would you be willing to post it?  I'm running into an "Incorrect Arguments" warning for both my = sign and my || sign.  I have:

f2 = f2 || number(o) >= obNum[k]

Thanks

Re: "Playing" With Filters
GregM_dxler - Wed Jun 05 10:49:35 EDT 2013

josiah820 - Wed Jun 05 10:27:42 EDT 2013

Do you happen to have the actual code for just the filter line and would you be willing to post it?  I'm running into an "Incorrect Arguments" warning for both my = sign and my || sign.  I have:

f2 = f2 || number(o) >= obNum[k]

Thanks

I have two arrays, sSections contains the section number to filter for and sNextSections is the section number for the next section.  Then the filter is made by the following:

{code}

      f1 = attribute "Object Number" >= sSections[iCnt]
      f1 = f1 && attribute "Object Number" < sNextSections[iCnt]
      for(iCnt=1;iCnt<iCntMax;iCnt++){
         f2 = attribute "Object Number" >= sSections[iCnt]
         f2 = f2 && attribute "Object Number" < sNextSections[iCnt]
         f1 = f1 || f2
      }//end for

{code}

The final filter is done by "set f1" and then refresh current Module.

Hope this comes out okay in the forum.

Greg

Re: "Playing" With Filters
GregM_dxler - Wed Jun 05 11:05:05 EDT 2013

GregM_dxler - Wed Jun 05 10:49:35 EDT 2013

I have two arrays, sSections contains the section number to filter for and sNextSections is the section number for the next section.  Then the filter is made by the following:

{code}

      f1 = attribute "Object Number" >= sSections[iCnt]
      f1 = f1 && attribute "Object Number" < sNextSections[iCnt]
      for(iCnt=1;iCnt<iCntMax;iCnt++){
         f2 = attribute "Object Number" >= sSections[iCnt]
         f2 = f2 && attribute "Object Number" < sNextSections[iCnt]
         f1 = f1 || f2
      }//end for

{code}

The final filter is done by "set f1" and then refresh current Module.

Hope this comes out okay in the forum.

Greg

The filter is a display filter, not an object filter (like accept o and reject o).  So the filter criteria is an attribute comparison.  There is a dxl command of includeLeaves.  I haven't used this, but it might do what you want by using it from the parent objects.  Just a thought...

Good luck

Re: "Playing" With Filters
llandale - Wed Jun 05 13:34:30 EDT 2013

josiah820 - Wed Jun 05 09:06:50 EDT 2013

Okay, I made some changes to the code and I THINK I made the right changes, but it's acting weird.  I edited my test module and put CR00444 into the "CR" attribute in one object.  However, when I run the program, every single object is "grayed out" (I'm assuming that means it was "rejected". yet EVERY object is exported in the "Export to Word" box.  Does accepting and rejecting not have any effect on if the object is exported or not, and how can I "hide" the objects that I don't want to be exported, based on what was accepted or rejected, so that only the "accepted" objects are included in the export?

Thanks for your help

Don't know about "greyed out". 

Line #106 you want "filtering on".  This applies all the accept/reject commands.

Line #107 I think you do want to "close m".

I think it cleaner to move line #68 "eval_..." to after line #104.

Line #40 "o = current".  STOP DOING THAT.  You are changing the specified Object "o".

  • void parentSibling(Object o)
  • {
  •    Object oParent, oChild
  •    oParent = parent(o)
  •    if (!null oParent)
  •    {  if (!isDeleted(oParent)) then accept oParent
  •       for oChild in oParent do
  •       {  if (!isDeleted(oChild)) then accept oChild 
  •       } // end for all siblings
  •    }    // end o has a parent
  • }

-Louie

Re: "Playing" With Filters
josiah820 - Wed Jun 05 14:18:05 EDT 2013

llandale - Wed Jun 05 13:34:30 EDT 2013

Don't know about "greyed out". 

Line #106 you want "filtering on".  This applies all the accept/reject commands.

Line #107 I think you do want to "close m".

I think it cleaner to move line #68 "eval_..." to after line #104.

Line #40 "o = current".  STOP DOING THAT.  You are changing the specified Object "o".

  • void parentSibling(Object o)
  • {
  •    Object oParent, oChild
  •    oParent = parent(o)
  •    if (!null oParent)
  •    {  if (!isDeleted(oParent)) then accept oParent
  •       for oChild in oParent do
  •       {  if (!isDeleted(oChild)) then accept oChild 
  •       } // end for all siblings
  •    }    // end o has a parent
  • }

-Louie

Okay, so I have this... and It's working, at least when it comes to recognizing when a module has no occurrences of the CR, but when it comes to a module that DOES have the CR in it, it exports the ENTIRE module, and I can't figure out why.  Any ideas?


Attachments

CR-CRG In Project Level Upb.dxl

Re: "Playing" With Filters
josiah820 - Wed Jun 05 14:31:43 EDT 2013

josiah820 - Wed Jun 05 14:18:05 EDT 2013

Okay, so I have this... and It's working, at least when it comes to recognizing when a module has no occurrences of the CR, but when it comes to a module that DOES have the CR in it, it exports the ENTIRE module, and I can't figure out why.  Any ideas?

It looks like it's going all of the way up to the "top" of the hierarchy and then going to the bottom, so that's why it's exporting everything

Re: "Playing" With Filters
llandale - Wed Jun 05 15:54:12 EDT 2013

josiah820 - Wed Jun 05 14:31:43 EDT 2013

It looks like it's going all of the way up to the "top" of the hierarchy and then going to the bottom, so that's why it's exporting everything

You need to turn on filtering BEFORE you try to export

Re: "Playing" With Filters
josiah820 - Wed Jun 05 15:59:08 EDT 2013

llandale - Wed Jun 05 15:54:12 EDT 2013

You need to turn on filtering BEFORE you try to export

Wowwwwww I'm smart.... *headdesk* thanks!! I got it!